package designpattern.chainresponsibility.order;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 刘牌
 * @Date: 2021/12/18/23:22
 * @Description:
 */
public class OrderService {

    public void saveOrder(Order order){
        //是否免单
        if (order.isFreeOrder()){
            System.out.println("免单");
        }
        //是否挂单
        else if (order.getHangOrderPersonId() != null){
            System.out.println("挂单操作");
        }
        //是否会员
        else if (order.getMemberId() != null){
            System.out.println("会员扣将");
        }
        FreeOrderHandler freeOrderHandler = new FreeOrderHandler();
        HangOrderHandler hangOrderHandler = new HangOrderHandler();
        MemberHandler memberHandler = new MemberHandler();

        freeOrderHandler.next(hangOrderHandler);
        hangOrderHandler.next(memberHandler);
        freeOrderHandler.hand(order);
    }
}
